package com.stlm2.controller;

import com.stlm2.dems.entity.GoodsObligation;
import com.stlm2.dems.service.GoodsObligationService;
import com.stlm2.util.codecontent.CodeContent;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * Created by zlq on 2017/10/18.
 */
@Controller
@RequestMapping("/goodsObligationC")
public class GoodsObligationController {
    @Resource
    private GoodsObligationService goodsObligationService;
    /*
        *zlq
        * 商品添加叮当猫服务承诺
        * token:
        * goodsId:商品ID
        * ddmObligationIds：叮当猫服务ID
         */
    @ResponseBody
    @RequestMapping(value="/add.json",produces="application/json;charset=UTF-8")
    public  String add(ModelMap model, String token,String goodsId,String ddmObligationIds){
        String data=null;
        try {
            data=goodsObligationService.add(model,token,goodsId,ddmObligationIds);
        }catch (Exception e){
            e.printStackTrace();
            return  CodeContent.getModelByCode(0,"添加失败",data);
        }
        return  data;
    }


	/*
*商品删除服务承诺
* zlq
* token:
* id: 记录ID
 */
    @ResponseBody
    @RequestMapping(value="/delete.json",produces="application/json;charset=UTF-8")
    public  String delete(ModelMap model, String token,String id){
        String data=null;
        try {
            data=goodsObligationService.delete(model,token,id);
        }catch (Exception e){
            e.printStackTrace();
            return  CodeContent.getModelByCode(0,"删除失败",data);
        }
        return  data;
    }

    /*
*zlq
* 商品查找叮当猫服务承诺列表
* token:
* goodsId:商品ID
 */
    @ResponseBody
    @RequestMapping(value="/getlist.json",produces="application/json;charset=UTF-8")
    public  String getlist(ModelMap model, String token,String goodsId){
        String data=null;
        try {
            data=goodsObligationService.getlist(model,token,goodsId);
        }catch (Exception e){
            e.printStackTrace();
            return  CodeContent.getModelByCode(0,"查询失败",data);
        }
        return  data;
    }

}
